package it.pecuswap.backend.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * The persistent class for the USERS database table.
 * 
 */
@Entity
@Table(name = "users", schema="pecuswapdb")
public class User implements Serializable, Cloneable {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = -176507093422590269L;
    
    long    id;

    private String  userName;
    private String  password;
    private String  firstName;
    private String  lastName;
    private Date dtOraInserimento;
    private Date dtOraUltMod;

    /**
     * Instantiates a new ateco codici.
     */
    public User() {
    }
    
    /**
     * Gets user id.
     * 
     * @return user id
     */
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="userid")
    public long getId() {
        return id;
    }
    
    public void setId(long id) {
        this.id = id;
    }     

    @Column(name="username",unique=true,nullable=false,length=50)
    @NotNull 
    @Size(min=3,max=16)
    public String getUserName() {
        return userName;
    }
    
    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name="password",nullable=false,length=50)
    @NotNull
    @Size(min=3,max=50)
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name="firstname",length=50)
    public String getFirstName() {
        return firstName;
    }
    
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    
    @Column(name="lastname",length=50)    
    public String getLastName() {
        return lastName;
    }
    
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    
    @Transient
    public boolean isAdmin() {
       return false;
    }

    /**
     * Gets the dt ora inserimento.
     * 
     * @return the dt ora inserimento
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "dt_ora_inserimento")
    public Date getDtOraInserimento() {
    	return this.dtOraInserimento;
    }

    /**
     * Sets the dt ora inserimento.
     * 
     * @param dtOraInserimento
     *            the new dt ora inserimento
     */
    public void setDtOraInserimento(Date dtOraInserimento) {
    	this.dtOraInserimento = dtOraInserimento;
    }

    /**
     * Gets the dt ora ult mod.
     * 
     * @return the dt ora ult mod
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "dt_ora_ult_mod")
    public Date getDtOraUltMod() {
    	return this.dtOraUltMod;
    }

    /**
     * Sets the dt ora ult mod.
     * 
     * @param dtOraUltMod
     *            the new dt ora ult mod
     */
    public void setDtOraUltMod(Date dtOraUltMod) {
    	this.dtOraUltMod = dtOraUltMod;
    }

    
    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#clone()
     */
    @Override
    public User clone() throws CloneNotSupportedException {
    	User u = new User();
    	return u;
    }

}